#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2017/12/22 16:11
# @Author  : Beam
# @Site    : 
# @File    : redisconnect.py
# @Software: PyCharm
'''
用于连接redis进行操作
'''
import redis


class ConRedis(object):
	def __init__(self,host,port,passwd,db=0):
		self.pool = redis.ConnectionPool(host=host, port=port,password=passwd,db=db,)  # 连接池方式连接,用第6这个库
		self.r = redis.Redis(connection_pool=self.pool)  # 建立redis连接

	def info(self):
		redisinfo = self.r.info()
		return redisinfo

	def keys(self):
		keysinfo = self.r.keys('*')
		newkeyslist = []
		for i in keysinfo:
			newkeyslist.append(str(i.decode('utf-8')))
		return newkeyslist



#调试
# obj = ConRedis('192.168.6.242','16379','6ai2xL7ky97hUAzXmDtTcyiQibUpNgKj',12)
# # print(obj.info())
# print(obj.keys())
# obj.r.lpush('info1','Beam','25','man','it','1992')
# obj.r.rpush('info2','Mity','25','lady','manager','1992')

